<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>信息列表选择</title>
	<#include "/common/resource.ftl">
    <style type="text/css">
        body{background:#EBEDED;}
        .ui-searchs {margin:2px 5px;}
        .ui-searchs div{display:inline-block;vertical-align:top;}
        .ui-searchs .left input{height:25px;line-height:25px;padding:0px 2px;}
    </style>
</head>
<body>

<#if params.model! == 'user'><#--用户-->
   <div class="ui-searchs">
        <div class="left"><input type="text" name="name" value="" placeholder="用户名称"/></div>
        <div class="right"><input type="button" value="搜索" class="layui-btn layui-btn-danger search-button"/></div>
    </div>
    <table id="datagrid" options="url:'${params.contextPath}/web/user/userList',dblClickRow:'onClickRow',params:'getSearchParams'">
        <thead>
            <tr>
                <th data-options="field:'name',width:100,align:'left'">姓名</th>
                <th data-options="field:'idcard',width:100,align:'left'">身份证号</th>
                <th data-options="field:'phone',width:100,align:'left'">联系方式</th>
            </tr>
        </thead>
    </table>
<#elseif params.model! == 'user1'>
    <div class="ui-searchs">
        <div class="left"><input type="text" name="name" value="" placeholder="用户名称"/></div>
        <div class="right"><input type="button" value="搜索" class="layui-btn layui-btn-danger search-button"/></div>
    </div>
    <table id="datagrid" options="url:'${params.contextPath}/web/user/userList',dblClickRow:'onClickRow',params:'getSearchParams'">
        <thead>
        <tr>
            <th data-options="field:'name',width:100,align:'left'">姓名</th>
            <th data-options="field:'idcard',width:100,align:'left'">身份证号</th>
            <th data-options="field:'phone',width:100,align:'left'">联系方式</th>
        </tr>
        </thead>
    </table>
<#elseif params.model! == 'elder'><#--机构-->
   <div class="ui-searchs">
        <div class="left"><input type="text" name="name" value="" placeholder="用户名称"/></div>
        <div class="right"><input type="button" value="搜索" class="layui-btn layui-btn-danger search-button"/></div>
    </div>
    <table id="datagrid" options="url:'${params.contextPath}/web/elder/list',dblClickRow:'onClickRow',params:'getSearchParams'">
        <thead>
            <tr>
                <th data-options="field:'name',width:100,align:'left'">姓名</th>
                <th data-options="field:'idcard',width:160,align:'left'">身份证号</th>
                <th data-options="field:'bedNum',width:150,align:'left'">床位号</th>
                <th data-options="field:'checkInDate',width:150,align:'left'">入住日期</th>
                <th data-options="field:'nursingLevelStr',width:100,align:'left'">护理等级</th>
            </tr>
        </thead>
    </table>   
</#if>

<script type="text/javascript">
    function getSearchParams() {
        return {
            name: $("input[name='name']").val() || "",
            code: $("input[name='code']").val() || ""
        };
    }

    var onClickRow = function (rowIndex, rowData) {
        //console.log("rowIndex = " + rowIndex);
        //console.log("rowData = " + JSON.stringify(rowData));
        rowData._model = '${params.model!}';
        LocalStorage.sendData("${params.handlerId!'single_select'}", rowData);
        parent.FormManager.closeSingleModelSelect();
    };

    $(function () {
        $(".search-button2").click(function () {
            var table = $("#ui-datagrid");
            table.datagrid("options").pageNumber = 1;
            table.datagrid({queryParams: getSearchParams()});
        });
    });
</script>
</body>

</html>
